home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <io.h>
- #include <fcntl.h>
- #include <sys/stat.h>
-
- #include "aspi.h"
- #include "tape.h"
-
- unsigned block_size = 20*512U;
- char *buffer;
-
- int data_f;
-
- void do_read(void)
- {
- int stat, i, c;
- unsigned long total = 0;
-
- tape_set_blocksize(block_size);
-
- while (1)
- {
- if (tape_read(buffer))
- break;
-
- write(data_f, buffer, block_size);
- total += block_size;
- printf(" %s\r", tape_fmtnum(total));
- fflush(stdout);
- }
- printf("\n", total);
- }
-
-
- int main(int argc, char **argv)
- {
- int stat;
- if (argc < 2)
- {
- printf("datread [-b blocks(512ea)] file\n");
- printf(" ex: blocks = 20 is 10K\n");
- return 1;
- }
-
- if (strcmp(argv[1], "-b") == 0)
- {
- block_size = atoi(argv[2]) * 512UL;
- argc -= 2;
- argv += 2;
- }
-
- data_f = open(argv[1], O_WRONLY|O_BINARY|O_CREAT|O_TRUNC, 0666);
- if (data_f < 0)
- {
- perror("Opening output data file");
- exit(1);
- }
-
- buffer = (char *)malloc(block_size);
- aspi_buffer_length = block_size;
- tape_open();
- do_read();
- tape_close();
-
- close(data_f);
-
- return 0;
- }
-